//
//  UserCenterHeaderView.m
//  ChineseCollegeStudentsNetwork
//
//  Created by 刘喆 on 2018/5/11.
//  Copyright © 2018年 刘喆. All rights reserved.
//

#import "UserCenterHeaderView.h"


@interface UserCenterHeaderView ()

@property (nonatomic, strong) UILabel *logintime;//最近一次登陆时间
@property (nonatomic, strong) UIButton *headerbutton; //点击换头像

@end

@implementation UserCenterHeaderView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = UIColor.whiteColor;
        [self createSubviews];
    }
    return self;
}

#pragma mark - Subviews
#pragma amrk layout subviews
- (void)layoutSubviewsInView {
    
    [_headerImgv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(60);
        make.centerX.equalTo(self);
        make.width.height.mas_equalTo(65);
    }];
    [_name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_headerImgv.mas_bottom).offset(25);
        make.centerX.equalTo(self);
        make.height.mas_equalTo(20);
    }];
    [_logintime mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self->_name.mas_bottom).offset(10);
        make.centerX.equalTo(self);
        make.height.mas_equalTo(15);
    }];
    [_headerbutton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(65);
        make.centerX.equalTo(self);
        make.width.height.mas_equalTo(65);
    }];
    
}


#pragma mark create subviews
- (void)createSubviews {
    
    [self addSubview:self.headerImgv];
    [self addSubview:self.name];
    //[self addSubview:self.logintime];
    [self addSubview:self.headerbutton];
    
    [self layoutSubviewsInView];
}

- (UIImageView *)headerImgv {
    if (!_headerImgv) {
        _headerImgv = [[UIImageView alloc] init];
        _headerImgv.image = [UIImage imageNamed:@"icon_app"];
    }
    return _headerImgv;
    
}

- (UILabel *)name {
    
    if (!_name) {
        _name = [[UILabel alloc] init];
        _name.text = @"您好";
        _name.font = [UIFont systemFontOfSize:20];
    }
    return _name;
}

- (UILabel *)logintime {
    if (!_logintime) {
        _logintime = [[UILabel alloc] init];
        _logintime.font = [UIFont systemFontOfSize:13];
    }
    
    return _logintime;
}

- (UIButton *)headerbutton {
    
    if (!_headerbutton) {
        _headerbutton = [UIButton buttonWithType:UIButtonTypeCustom];
        _headerbutton.titleLabel.font = [UIFont boldSystemFontOfSize:11];
        _headerbutton.layer.cornerRadius = 12.5;
        _headerbutton.layer.masksToBounds = YES;
    }
    return _headerbutton;
}


@end
